import java.util.Scanner;

public class test14 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int number = in.nextInt(); //需要处理的组数
        for (int i = 0; i < number; i++) {
            int n = in.nextInt(); //会输入的字符串个数
            String[] strings = new String[n]; //字符串
            for (int j = 0; j < n; j++) {
                strings[j] = in.next(); //字符串
            }
            System.out.println(getResult(strings));
        }
    }
    public static String getResult(String[] strings){
        if (strings.length == 0 ){
            return "Yes";
        }
        // 直接两个指针
        int left=0,right=strings.length-1;
        while (left<=right){
            // 这样单数个数就可以直接判定了
            if(!strings[left].equals(strings[right]))
                return "No";
            left++;
            right--;
        }
        return "Yes";
    }
}
